import { createStore } from 'vuex'
import { ElNotification } from 'element-plus'

export default createStore({
  state: {
    dialog1:false,
    dialog2:false,
    user:'',
    user_id:JSON.parse(localStorage.getItem('user_id'))|| '',
    cate: JSON.parse(localStorage.getItem('cartList')) || [],
    da:[],
    cartList:[],
  },
  getters: {
  },
  mutations: {
    sett(state,set){
      state.da = set;
    },
    dialog1Change(state,){
      state.dialog1 = ! state.dialog1
    },
    dialog2Change(state){
      state.dialog2 = !state.dialog2
    },
    getcart(state,item) {
      state.cartList = [...item];
      localStorage.setItem('cartList',JSON.stringify(state.cartList))
    },
    Dl(state,form){
      state.user = form;
      state.user_id = form.user_id;
        localStorage.setItem('user',state.user);
        localStorage.setItem('user_id',state.user_id)
        localStorage.setItem('userName',form.userName)
    },
    Esc(state){
      state.user = '';
      localStorage.removeItem('userName')
      localStorage.removeItem('user_id')
      localStorage.removeItem('user')
    },
    // AddCate(state,obj){
    //   console.log(obj);
    //   state.cartList = obj;
    //   // localStorage.setItem('cartList',JSON.stringify(state.cartList))
    // }
  },
  actions: {
  },
  modules: {
  }
})
